import pagination from '@/views/pagination'  //分页组件
import dialogForm from './edit'
import agentHttp from '@/utils/agentHttp.js'
import {debounce} from '@/utils/index.js'
export default {
  name: 'priceAudit',
  created(){
     this.seachData(this.searchForm);
     this.getStatusMap();
  },
  components:{dialogForm,pagination},
  data() {
  	return {
      //搜索字段
  		searchForm:{
  			dealerName:"",
  			priceStatus:"",
  			carBrandNameAndCarName:"",
        orderNumber:"",
        startDate:"",
        endDate:"",
  		},
      //表格字段
      tableData: [],
         
      formLabelWidth:'120px',
      statusMap:'',
      //发送给弹窗的数据
      dialogSendData:{
        isAdd:true,                //是否为编辑或者新增  true是   false否
        dialogFormVisible:false,   //弹窗是否显示        true是   false否
        id:""          //请求参数            自定义 例如index或者id
      },
      startDateOpt: {
        disabledDate(time) {
          return time.getTime() > Date.now() 
        }
      },
      endDateOpt:{
        disabledDate:(time)=>{
          return  time.getTime()< new Date(this.searchForm.startDate).getTime();
        }
      },
      resetFormStatus:false
      
  	}
  },

  methods: {
    seachData(){
      if(!this.resetFormStatus){
        var params=this.searchForm||{};
        params.page=this.tableData.page||1;
        params.rows=this.tableData.rows||10;
        agentHttp.postJson('adminApi/admin/car_order_price/order_list?page='+params.page+'&rows='+params.rows,params ).then((data)=>{
              this.tableData = data
        })
      }
    },
    debounceSeach(){
      this.tableData.page=1;
      debounce(this.seachData(this.searchForm),1000)
    },
    //重置
    resetSearchForm(formName) {
      this.resetFormStatus=true;
      this.tableData.page=1;
      this.tableData.rows=10;
      this.$refs[formName].resetFields();
      this.$nextTick(_ =>{
        this.resetFormStatus=false;
        this.seachData();
      })
    },
    /*表格操作按钮*/
    //查看
    handleSee(index, row){
      this.dialogSendData.isAdd=false;
      this.dialogSendData.id=row.id;
      this.dialogSendData.dialogFormVisible=true;
    },
    handleEdit(index, row){
      this.dialogSendData.isAdd=true;
      this.dialogSendData.id=row.id;
      this.dialogSendData.dialogFormVisible=true;
    },
    getStatusMap(){
      agentHttp.get('adminApi/admin/car_order_price/get_status_map' ).then((data)=>{
        this.statusMap = data.data;
      })  
    }
   
  }
}